//
//  UIView+Extwnsion.swift
//  sina
//
//  Created by 崔正强 on 17/3/22.
//  Copyright © 2017年 崔正强. All rights reserved.
//

import UIKit

extension UILabel {
    convenience init(title: String, textColor:UIColor, fontSize: CGFloat) {
        self.init()
        //给label设置基本的属性
        self.text = title
        self.textColor = textColor
        self.font = UIFont.systemFont(ofSize: fontSize)
        //换行
        self.numberOfLines = 0
        //文字居中显示
        self.textAlignment = .center
        //自适应大小
        self.sizeToFit()
    }
    
}

extension UIButton {
    convenience init(title: String, textColor: UIColor, fontSize: CGFloat, backImageName: String, imageName: String? = nil) {
        self.init()
        self.setTitle(title, for: .normal)
        self.setTitleColor(textColor, for: .normal)
        self.setBackgroundImage(UIImage(named: backImageName), for: .normal)
        self.titleLabel?.font = UIFont.systemFont(ofSize: fontSize)
        if let img = imageName {
            self.setImage(UIImage(named: img), for: .normal)
        }
    }
    
    
}
